package org.example.servlet;

import org.example.other.ErrorEnum;
import org.example.other.ServiceException;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 用于测试父类BaseServlet的功能
 */
@WebServlet(urlPatterns = "/hello")
public class HelloServlet extends BaseServlet{
    @Override
    protected void handleRequest(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        String name = req.getParameter("name");
        if (name == null) {
            throw new ServiceException(ErrorEnum.SERVER_ERROR);
        }else {
            success(resp, "welcome!");
        }
    }
}
